using System;
using System.Collections;
using System.Text;
using Friendster.Service;
using System.Configuration;

namespace Friendster.Service.Core
{
    public class FriendsterSession
    {
        // Fields
        private string _appKey;
        private string[] _friendIDs;
        private string _secret;
        private bool _sessionExpires;
        private string _sessionKey;
        private string _userID;

        // Methods
        protected FriendsterSession()
        {
            this._appKey = ConfigurationSettings.AppSettings["APIKey"];
            this._secret = ConfigurationSettings.AppSettings["Secret"];
        }
        static FriendsterSession()
        {
            //InitializeSession((string)table["session_key"]);
            //InitializeUserID((string)table["uid"]);
        }
        //protected void InitializeFriends(string[] friendIDs);
        protected void InitializeSession(string sessionKey)
        {
            if (!string.IsNullOrEmpty(sessionKey) || !sessionKey.Contains("widget_login"))
                this._sessionKey = sessionKey;
            else
                throw new InvalidOperationException("Invalid session key. Cannot initialize session");
        }
        protected void InitializeUserID(string userID)
        {
            if(!string.IsNullOrEmpty(userID))
                this._userID = userID;
            else
                throw new InvalidOperationException("Cannot initialize a null user");
        }

        // Properties
        public string ApplicationKey 
        {
            get
            {
                return this._appKey;
            }
        }
        internal string[] FriendIDs 
        {
            get
            {
                return this._friendIDs;
            }
        }
        public string Secret 
        {
            get
            {
                return this._secret;
            }
        }
        public string SessionKey 
        {
            get
            {
                return this._sessionKey;
            }
        }
        public string UserID 
        {
            get
            {
                return this._userID;
            }
        }
    }
}